import request from '@/router/axios';

export const savaStorageFileRecord = (formData) => {
  
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: '/api/file-api/mx-file/savaStorageFileRecord',
    method: 'post',
    data: formData
  })
}

export const checkChunkUpload = (params) => {
  return request({
    url: '/api/file-api/mx-file/checkChunkUpload',
    method: 'get',
    params: {
      ...params,
    }
  })
}

export const uploadStorageFile = (formData) => {
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: '/api/file-api/mx-file/uploadStorageFile',
    method: 'post',
    data: formData
  })
}
export const del = (data) => {
  return request({
    url: '/api/file-api/mx-file/deleteChunkFile',
    method: 'post',
    params: data
  })
}

export const getList = (params) => {
  return request({
    url: '/api/file-api/mx-file/chunkFilePage',
    method: 'post',
    params: {
      ...params,
    }
  })
}

export const downloadStorageFile = (params) => {
  return request({
    url: '/api/file-api/mx-file/downloadChunkFile',
    method: 'get',
    params: {
      ...params,
    }
  })
}
export const taskInfo = (identifier) => {
  return request({
    url: `/api/file-api/mx-file/${identifier}`,
    method: 'get',
  })
}

export const initTask = ({ identifier, fileName, totalSize, chunkSize }) => {
  return request({
    url: '/api/file-api/mx-file/init',
    method: 'post',
    data: {
      identifier, fileName, totalSize, chunkSize
    }
  })
}
export const preSignUrl = ({ identifier, partNumber }) => {
  return request({
    url: `/api/file-api/mx-file/${identifier}/${partNumber}`,
    method: 'get',
  })
}

export const merge = (identifier) => {
  return request({
    url: `/api/file-api/mx-file/merge/${identifier}`,
    method: 'post',
  })
}

// 静态文件上传

export const uploadSource = (formData) => {
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: '/api/file-api/mx-resource-file/uploadFile',
    method: 'post',
    data: formData
  })
}

// 静态文件列表
export const getSourceList = (params) => {
  return request({
    url: '/api/file-api/mx-resource-file/page',
    method: 'get',
    params: {
      ...params,
    }
  })
}

// 静态文件删除
export const delSource = (data) => {
  return request({
    url: '/api/file-api/mx-resource-file/delete',
    method: 'post',
    params: data
  })
}
